<template>
  <div class="app-container">
    <div class="search-box">
      <div class="search-hd">组织管理</div>
      <div class="search-bd">
        <el-button type="success" size="small">新增</el-button>
      </div>
    </div>
    <div class="main-box">
      <div class="main-hd">组织管理</div>
      <el-table
        v-loading="loading"
        :data="list"
        stripe
        max-height="500"
        fit
        highlight-current-row
      >
        <el-table-column  label="序号" width="95" align="center">
          <template slot-scope="scope">
            {{ scope.$index }}
          </template>
        </el-table-column>
        <el-table-column label="组织名称" prop="projectName" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="success" size="mini" @click="edit(scope.row)">修改</el-button>
            <el-button type="danger" size="mini" @click="del(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="page-box">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="searchField.page"
          :page-sizes="[10, 15, 20, 25, 30, 50]"
          :page-size="searchField.limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import { getProjectList } from '@/api/table'

export default {
  data() {
    return {
      list: null,
      loading: true,
      total: 10,
      searchField: {
        page: 1,
        limit: 15
      }
    }
  },
  created() {
    this.initListData()
  },
  methods: {
    // 查看
    showDetail(row) {
      console.log(row)
    },
    // 编辑
    edit(row) {
      console.log(row)
    },
    // 删除
    del(row) {
      console.log(row)
    },
    initListData() {
      this.loading = true
      getProjectList().then(response => {
        this.list = response.data.items
        this.total = this.list.length
        this.loading = false
      })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
}
</script>

<style lang="scss" scoped>
.redColor{
  color: red;
}
.search-box{
  margin-bottom: 15px;
  .search-hd{
    border-left: 2px solid #00a73c;
    padding: 10px;
    margin-bottom: 10px;
  }
  .search-bd{
    .el-button--small{
      margin-top: 3px;
    }
  }
}
.main-box{
  .main-hd{
    height: 40px;
    line-height: 40px;
    background: #00a73c;
    color: #fff;
    padding-left: 10px;
  }
  .page-box{
    padding: 10px;
    text-align: center;
  }
}
</style>
